Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a VM DRS Override module #2229

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

svg1007
Copy link

@svg1007 svg1007 commented Oct 31, 2024

SUMMARY

This PR contains a new Ansible module, vmware_drs_override, to the community.vmware collection. The module allows users to configure Distributed Resource Scheduler (DRS) behavior overrides for individual VMs within a VMware vSphere cluster. This provides users with enhanced control over VM placement, resource allocation, and automation behavior by enabling DRS settings specific to each VM rather than relying solely on cluster-wide configurations.

Key design decisions include:

  • Encapsulating functionality in a class to streamline the connection, VM lookup, and DRS configuration processes.
  • Ensuring the module aligns with other community.vmware modules in terms of structure, error handling, and documentation.

This PR does not fix a pre-existing issue but adds new functionality to enhance VMware DRS management in the community.vmware collection.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

vmware_drs_override

ADDITIONAL INFORMATION

The vmware_drs_override module provides the following parameters:

  • hostname, username, password, and port for vCenter server access.
  • validate_certs to handle SSL verification.
  • vm_name and drs_behavior to specify the VM and desired DRS configuration (options include manual, partiallyAutomated, and fullyAutomated).

This module was tested using a local vCenter environment to verify correct DRS behavior application and task handling. Example playbook and command output are provided below to demonstrate module functionality.

# Example playbook:
- name: Test VMware DRS Override Module
  hosts: localhost
  gather_facts: false
  tasks:
    - name: Apply DRS override to VM
      community.vmware.vmware_drs_override:
        hostname: "vcenter.example.com"
        username: "[email protected]"
        password: "yourpassword"
        port: 443
        validate_certs: False
        vm_name: "my_vm_name"
        drs_behavior: "manual"
      register: result

    - name: Show Result
      debug:
        var: result

plugins/modules/vmware_drs_override.py Outdated Show resolved Hide resolved
plugins/modules/vmware_drs_override.py Outdated Show resolved Hide resolved
plugins/modules/vmware_drs_override.py Outdated Show resolved Hide resolved
@ihumster
Copy link
Collaborator

@mariolenz I left a few comments. Perhaps you will find some other recommendations for the author.

Copy link

@svg1007
Copy link
Author

svg1007 commented Nov 1, 2024

@ihumster , please take a look.

@Rogacz
Copy link

Rogacz commented Nov 6, 2024

Hi,
It's awesome you wrote it as I'm in need of this functionality too :)

As you're already using get_vm can you add folder and datacenter parameters to allow for precise search of vm?
Also as alternative uuid with optional flag use_instance_uuid and third option to use moid same as for example vmware_guest_snapshot

Thanks!

@ihumster
Copy link
Collaborator

ihumster commented Nov 6, 2024

@svg1007 LGFM, let's wait @mariolenz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants